<?php
	$_products = $this->getProductCollection();
	$_helper = $this->helper('catalog/output');
	
	$limitproduct = $this->getLimitCount();
	$size = $_products->getSize();
	if($limitproduct == "" || $limitproduct > $size){
		$limitproduct = $size;
	}
	
	$w = $this->getThumbnailWidth();
	$h = $this->getThumbnailHeight();
	$_columnCount = $this->getColumnCount();
	$alt_img = $this->getAltImg();
	   
	/* slider config */
	$idJs = "em_minifilter_products_".md5(uniqid(rand()));    
	   if ($this->getData('slider_unique_id'))
		$idJs = $this->getData('slider_unique_id');
	$this->idJs = $idJs;
?>
<div id="<?php echo $idJs;?>" class="em-grid-16 <?php if($this->getCustomClass()): ?><?php echo $this->getCustomClass();?><?php endif; ?>">
	<?php if($this->getFrontendTitle()): ?>
		<div class="widget-title em-widget-title">
			<h3><span><?php echo $this->getFrontendTitle(); ?></span></h3>
		</div>
	<?php endif; ?>
    
	<?php if($this->getFrontendDescription()):?>
	<div class="desc"><?php echo $this->getFrontendDescription(); ?></div>
	<?php endif ?>
    
	<?php if ($limitproduct): ?>
	<div class="widget em-filterproducts-custom">
		<div class="em-inner-product custom-product-list">			
				<?php $i=0; foreach ($_products as $_product): ?>
                    <?php if($i==0):?>
                        <div class="col-sm-12 em-item-big products-grid line-right">
							<div class="item">
								<div class="product-item">
									<div class="product-shop-top">
										<?php if ($this->getShowFrontend('thumb')): ?>
											<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image ">
												<?php if ($this->getShowFrontend('label') && Mage::helper('core')->isModuleEnabled('EM_Productlabels')):?>
												<!--show label product - label extension is required-->
												<?php Mage::helper('productlabels')->display($_product);?>
												<?php endif;?>
												
												<?php if ($alt_img): ?>                            
												<img class="em-alt-hover img-responsive <?php if($this->getData('img_lazyload')): ?>em-img-lazy<?php endif;?>" <?php if($this->getData('img_lazyload')): ?>src="<?php echo $this->getSkinUrl('images/loading.gif') ?>" data-original="<?php echo $this->helper('catalog/image')->init($_product, $alt_img)->resize($w,$h) ?>"<?php else:?>src="<?php echo $this->helper('catalog/image')->init($_product, $alt_img)->resize($w,$h) ?>"<?php endif;?> width="<?php echo $w; ?>" height="<?php echo $h ;?>" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" />
												<?php endif ?>
												<img class="img-responsive <?php if($this->getData('img_lazyload')): ?>em-img-lazy<?php endif;?> <?php if ($alt_img): ?>em-alt-org<?php endif ?>" <?php if($this->getData('img_lazyload')): ?>src="<?php echo $this->getSkinUrl('images/loading.gif') ?>" data-original="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($w,$h) ?>"<?php else:?>src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($w,$h) ?>"<?php endif;?> width="<?php echo $w; ?>" height="<?php echo $h ;?>" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" />                        
											</a>
										<?php else: ?>
											<?php if ($this->getShowFrontend('label') && Mage::helper('core')->isModuleEnabled('EM_Productlabels')):?>
											<!--show label product - label extension is required-->
											<?php Mage::helper('productlabels')->display($_product);?>
											<?php endif;?>
										<?php endif; ?>
										<div class="em-element-display-hover bottom">
											<?php if($this->getShowFrontend('addtocart') || $this->getShowFrontend('addto')): ?>
												<div class="em-btn-addto">
													<!--product add to cart-->
													<?php if ($this->getShowFrontend('addtocart')):?>
													<?php if ($_product->isSaleable()): ?>
													<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
													<?php else: ?>
													<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
													<?php endif; ?>
													<?php endif; ?>
													<!--product add to compare-wishlist-->
													<?php if($this->getShowFrontend('addto')):?>
													<ul class="add-to-links">
														<?php if ($this->helper('wishlist')->isAllow()) : ?>
														<li><a href="<?php echo $this->getAddToWishlistUrl($_product) ?>" class="link-wishlist" title="<?php echo $this->__('Add to Wishlist') ?>"><?php echo $this->__('Add to Wishlist') ?></a></li>
														<?php endif; ?>
														<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
														<li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare" title="<?php echo $this->__('Add to Compare') ?>"><?php echo $this->__('Add to Compare') ?></a></li>
														<?php endif; ?>
													</ul>
													<?php endif; ?>
												</div>
											<?php endif;?>
                                            <?php if(Mage::helper('core')->isModuleEnabled('EM_Quickshop') && Mage::helper('quickshop')->getConfig('enable')): ?>
											<div class="quickshop-link-container hidden-xs">
												<a href="<?php echo Mage::helper('quickshop/links')->addQuickShopLink($_product->getProductUrl()); ?>" class="quickshop-link" title="<?php echo $this->__('Product Quick View: ') ?><?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $this->__('Quickshop') ?></a>
											</div>
                                            <?php endif;?>
										</div>
									</div>
									<div class="product-shop">
										<div class="f-fix">
											<!--product name-->
											<?php if ($this->getShowFrontend('name')):?>
											<h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName() , 'name') ?></a></h3>
											<?php endif;?>
											<?php if ($this->getShowFrontend('sku')):?>
											<p class="sku"><?php echo $_product->getSku(); ?></p>
											<?php endif ;?>
											<!--product description-->
											<?php if ($this->getShowFrontend('desc')):
												$desc = $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description');
												if(strlen($desc)>80) {
													$strCutTitle = substr($desc, 0, 80);
													$desc = substr($strCutTitle, 0, strrpos($strCutTitle, ' '));
												}
											?>
											<p class="desc"><?php echo $desc; ?></p>
											<?php endif ;?>
											<!--product reviews-->
											<?php if ($this->getShowFrontend('review')):?>
											<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
											<?php endif ; ?>
											<!--product price-->
											<?php if ($this->getShowFrontend('price')):?>
												<?php if (Mage::helper('catalog')->canApplyMsrp($_product)):?>
													<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $this->__('Detail') ?></a>
												<?php else : ?>
													<?php echo $this->getPriceHtml($_product, true, "-emprice-".md5(uniqid(rand())) ) ?>
												<?php endif;?>
											<?php endif;?>
										</div>
									</div>
								</div>
                            </div>
        				</div>
                    <?php else:?>
                        <?php if($i==1):?>
                        <div class="col-sm-12 products-list line-left">
                        <?php endif;?>
                            <div class="<?php if($itemClass = $this->getData('item_class')) echo $itemClass.' '; ?>item<?php echo $_columnCount > 0 && $i%$_columnCount==0 || $_columnCount <= 0 && $i == 0 ?' first':''; ?><?php echo $_columnCount > 0 && ($i+1)%$_columnCount==0 || $i+1 == $limitproduct ?' last':''; ?>"
            					style="<?php echo $this->getItemWidth() ? 'width:'.$this->getItemWidth().'px;' : '' ?> <?php echo $this->getItemHeight() ? 'height:'.$this->getItemHeight().'px;' : '' ?> <?php echo $this->getItemSpacing() ? 'margin-bottom:'.$this->getItemSpacing().'px;' : '' ?>">
            					<?php if ($this->getShowFrontend('thumb')): ?>
            					<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image ">
            						<?php if ($this->getShowFrontend('label') && Mage::helper('core')->isModuleEnabled('EM_Productlabels')):?>
            						<!--show label product - label extension is required-->
            						<?php Mage::helper('productlabels')->display($_product);?>
            						<?php endif;?>
                                    
            						<?php if ($alt_img): ?>                            
                                    <img class="em-alt-hover img-responsive <?php if($this->getData('img_lazyload')): ?>em-img-lazy<?php endif;?>" <?php if($this->getData('img_lazyload')): ?>src="<?php echo $this->getSkinUrl('images/loading.gif') ?>" data-original="<?php echo $this->helper('catalog/image')->init($_product, $alt_img)->resize(120,120) ?>"<?php else:?>src="<?php echo $this->helper('catalog/image')->init($_product, $alt_img)->resize(120,120) ?>"<?php endif;?> width="120" height="120" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" />
            						<?php endif ?>
            						<img class="img-responsive <?php if($this->getData('img_lazyload')): ?>em-img-lazy<?php endif;?> <?php if ($alt_img): ?>em-alt-org<?php endif ?>" <?php if($this->getData('img_lazyload')): ?>src="<?php echo $this->getSkinUrl('images/loading.gif') ?>" data-original="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(120,120) ?>"<?php else:?>src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(120,120) ?>"<?php endif;?> width="120" height="120" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" />
            					</a>
            					<?php else: ?>
            					<?php if ($this->getShowFrontend('label') && Mage::helper('core')->isModuleEnabled('EM_Productlabels')):?>
            					<!--show label product - label extension is required-->
            					<?php Mage::helper('productlabels')->display($_product);?>
            					<?php endif;?>
            					<?php endif; ?>
            					<div class="product-shop">
            						<div class="f-fix">
            							<!--product name-->
            							<?php if ($this->getShowFrontend('name')):?>
            							<h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName() , 'name') ?></a></h3>
            							<?php endif;?>
            							<?php if ($this->getShowFrontend('sku')):?>
            							<p class="sku"><?php echo $_product->getSku(); ?></p>
            							<?php endif ;?>
            							<!--product description-->
            							<?php if ($this->getShowFrontend('desc')):
            								$desc = $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description');
            								if(strlen($desc)>80) {
            									$strCutTitle = substr($desc, 0, 80);
            									$desc = substr($strCutTitle, 0, strrpos($strCutTitle, ' '));
            								}
            								?>
            							<p class="desc"><?php echo $desc; ?></p>
            							<?php endif ;?>
            							<!--product reviews-->
            							<?php if ($this->getShowFrontend('review')):?>
            							<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
            							<?php endif ; ?>
            							<!--product price-->
            							<?php if ($this->getShowFrontend('price')):?>
            								<?php if (Mage::helper('catalog')->canApplyMsrp($_product)):?>
            									<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $this->__('Detail') ?></a>
            								<?php else : ?>
            									<?php echo $this->getPriceHtml($_product, true, "-emprice-".md5(uniqid(rand())) ) ?>
            								<?php endif;?>
            							<?php endif;?>
                                        
                                       
            						</div>
            					</div>
            				</div>
                        <?php if($i>=$limitproduct):?>
                        </div> 
                        <?php endif;?>        				                           
                    <?php endif;?>
				
				<?php $i++;?>
				<?php if($i >= $limitproduct) break;?>
				<?php endforeach; ?>
			</div>			
		</div>
	</div>
</div>
<?php else:?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php endif; ?>
